//逻辑运算符

//取反！
let a = true;
// - 如果是布尔值，直接取反

a = !a;//false
// 如果不是布尔值，先转换为布尔值，再取反
a = !0;//true
//可以让任意值取两次反，将该值转换为boolean
a = !!undefined;//false

console.log(a);

//逻辑与&&
let res1 = false && true;
res1 = 2 && 1;//1
res1 = 0 && 1;//0
res1 = 0 && NaN;//0
res1 =  NaN && 0;//NaN

console.log(res1);

//逻辑或||
let res2 = false || true;
res2 = 2 || 1;//2
res2 = 1 || 2;//1
res2 = 0 || 1;//1

res2 = 0 || NaN;//NaN
res2 =  NaN || 0;//0

console.log(res2);